package com.vehicle.admin.web.Redis;

import com.vehicle.common.redis.manager.CacheManager;
import com.vehicle.common.util.common.GenericHelper;
import com.vehicle.common.util.Jsons;

/**
 * Created by yantingbin on 2017/7/11.
 */
public class Student<K,V> extends People<K,V> {
    private CacheManager cacheManager;
    public Student(CacheManager cacheManager){
        this.cacheManager=cacheManager;
    }
    public void sayHi(V value){
        System.out.println(value.getClass());
    }
    public void sayHello(){
        System.out.println(GenericHelper.getClz(this.getClass(),1));
    }

    public V getData(K k){
       if (k instanceof String) {
            return cacheManager.get((String) k, GenericHelper.getClz(this.getClass(), 1));
        } else {
            return cacheManager.get(Jsons.toJson(k), GenericHelper.getClz(this.getClass(), 1));
        }
    }

    public void putData(K k,V v){
        if (k instanceof String) {
            cacheManager.set((String) k, v);
        } else {
            cacheManager.set(Jsons.toJson(k), v);
        }
    }
}
